$(document).ready(function(){
	$(document).on("pageInit", "#Ucvipbuy", function(e, id, page) {
		var vip_data =$("#uc_vip_buy #vip_data").val();
		vip_data = $.parseJSON(vip_data);
		var JVipBuy_From_Lock = false;
		$("#uc_vip_buy #Jvip_years").change(function(){
				setVipResult(vip_data);
		});
				
		$("#uc_vip_buy #vip_id").change(function(){
			setVipResult(vip_data);
		});
		
		setVipResult(vip_data);
		
		$("#uc_vip_buy  #vip_submitt").click(function(){
			if(JVipBuy_From_Lock==true) return ;
			$.showIndicator();
			JVipBuy_From_Lock = true;
			var ajaxurl = SITE_DOMAIN + '/index.php?m=Home&c=ucsavevipbuy';
			var years =  $.trim($("#Jvip_years").val());
			var vip_id =  $.trim($("#vip_id").val());
			var paypassword =  $.trim($("#paypassword").val());
			var query = newObject();
			query.years = $.trim($("#Jvip_years").val());
			query.vip_id = $.trim($("#vip_id").val());
			query.paypassword = $.trim($("#paypassword").val());
			
			query.post_type = "json";
			$.ajax({
				url:ajaxurl,
				data:query,
				type:"Post",
				dataType:"json",
				success:function(data){
					$.hideIndicator();
					JVipBuy_From_Lock = true;
					$.alert(data.show_err,function(){
						if(data.status == 1){
							reloadpage(SITE_DOMAIN + '/index.php?m=Home&c=uccenter','#Uccenter','.content',function(){
								RouterURL(SITE_DOMAIN + '/index.php?m=Home&c=ucvipbuylog');
							});
						}
					});
					
					
				}
			
			});
			  
		});
	});
});

function setVipResult(vip_data){
	var vip_id =  $("#vip_id").val() == undefined ? 0 : parseInt($("#vip_id").val());
	var years =  parseInt($("#Jvip_years").val());
	
	
	var site_pirce = vip_data[vip_id] == undefined ? 0 : vip_data[vip_id].site_pirce ;
	var original_price = vip_data[vip_id] == undefined ? 0 : vip_data[vip_id].original_price ;
	
	
	$("#uc_vip_buy #Jvip_site_pirce").html((site_pirce)+".00 元");
	$("#uc_vip_buy #Jvip_original_price").html((original_price)+".00 元");
}	

	